var api = require('../../../config/api.js');
var util = require('../../../utils/util.js');
var user = require('../../../utils/user.js');

var app = getApp();
Page({
  accountLogin: function() {
    wx.navigateTo({
      url: "/pages/auth/accountLogin/accountLogin"
    });
  },

  newLoginApi(){
      wx.getUserProfile({
        desc: '获取你的昵称、头像、地区及性别',
        success:e=>{
            console.log('用户信息:',e)
            user.loginByWeixin(e.userInfo).then(res => {
                app.globalData.hasLogin = true;
                wx.navigateBack({
                  delta: 1
                })
              }).catch((err) => {
                app.globalData.hasLogin = false;
                util.showErrorToast('微信登录失败');
              });
        }
      })
  }
})